<!--
 * @Description: 
 * @Author: mmzhang
 * @Date: 2022-11-14 10:12:04
 * @LastEditTime: 2022-12-21 11:14:43
-->
<template>
  <div class="channel-audit">
    <dt-search  ref="search" :label-width="128">
      <Button v-if="unlocking('0110020100')" type="primary" @click="onAdd">新增</Button>
      <Button type="primary" style="margin-left:10px;"> <a
          href="https://images.tospurfang.com/doc/%E7%94%B2%E6%96%B9%E4%B8%9A%E7%BB%A9%E7%A1%AE%E8%AE%A4%E8%AF%81%E6%98%8E%E6%93%8D%E4%BD%9C%E8%AF%B4%E6%98%8E.pdf"
          style="color:#fff;" target="_blank">查看操作指引</a>
      </Button>
    </dt-search>

    <dt-grid ref="table" page :onFetch='onFetch'/>
    <!-- 编辑弹框 -->
    <edit-modal ref="editModal" @onSearch="searchFun" />
  </div>
</template>

<script>
  import editModal from './components/edit-modal.vue'
  import toolMgr from '@/biz/base/tool.js'
  import proveMgr from '@/biz/caseReport/ownerProve.js'
  import proveColumn from './components/column'
  import searchOpt from './components/search'

  export default {
    components: {
      editModal
    },
    data() {
      return {
        searchInfo:{
          flag:'',
          userName:''
        }
      }
    },
    activated() {
      this.$refs.table.init(this, new proveColumn(this))
      this.$refs.search.init(this.$refs.table, new searchOpt(this).options(), this
        .searchInfo)
      this.$refs.table.fetch()
    },
    mounted() {},
    methods: {
      onFetch(data) {
        return proveMgr.list({
          ...data,
          buildingId:this.$dt.buildInfo().housesId
        }).then(res => {
          return {
            list:res.records,
            total:res.total
          }
        })
      },
      searchFun(val) {
        this.$refs.table.fetch()
      },
      // 新增
      onAdd() {
        this.$refs.editModal.show({})
      },
      // 编辑
      onEdit(data) {
        proveMgr.info(data.proveId).then(res => {
          this.$refs.editModal.show(res)
        })
      },
      // 下载附件
      onDownload(data) {
        toolMgr.downloadCenter(
          '/dt-risk/rkPartyProve/fileDown/[id]',
          {
            id: data.proveId
          }
        )
      },
      // 删除
      onDelete(data) {
        this.$Modal.confirm({
          title: '删除',
          content: '<p>确定要删除该业绩确认证明吗？</p>',
          onOk: () => {
            proveMgr.del([data.proveId]).then(() => {
              this.$Message.success('删除成功');
              this.$refs.table.fetch()
            })
          }
        })
      }
    },
  }
</script>

<style lang="scss" scoped>
  .channel-audit {
    padding: 20px;
  }
</style>